package cn.szzsi._web;

import cn.szzsi.common.model.Admanage;
import cn.szzsi.common.model.Product;
import cn.szzsi.common.model.zshop.PlateformConfig;
import cn.szzsi.interceptor.CommonInterceptor;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;
import com.jfinal.plugin.redis.Redis;

import java.math.BigDecimal;
import java.util.List;

public class DiscountController extends BaseWebController<Product> {
    private String shopId;//店铺id

    private List<Product> bestProductList;
    private List<Product> hotProductList;
    private List<Product> newProductList;


    @Clear
    public void index() {
        shopId = getPara("shopId");
        List<Product> cheapProductList = Product.dao.getCheapProductList(shopId);
        List<Admanage> admanagesDiscount = Admanage.dao.getByUidAndAdTypeId(shopId, 5);
        setAttr("cheapProductList", cheapProductList);
        setAttr("admanagesDiscount", admanagesDiscount);
        getTemplatePath(shopId, "discount");

    }

    /**
     * 特惠专区
     */
    @Clear
    @Before(CommonInterceptor.class)
    public void discountPlateform() {
        List<Product> cheapProductList = Product.dao.getCheapProductListAll();
        List<Admanage> admanagesDiscount = Admanage.dao.getByUidAndAdTypeId("-1", 5);
        setAttr("cheapProductList", cheapProductList);
        setAttr("admanagesDiscount", admanagesDiscount);
        getTemplatePath(shopId, "discount");
    }

    @Clear
    @Before(CommonInterceptor.class)
    public void bestProductList() {
        bestProductList = Product.dao.getPlatformBestProductList();
        setAttr("bestProductList", bestProductList);
        wapTemplatePath("best_product_list.html");
    }

    @Clear
    @Before(CommonInterceptor.class)
    public void newProductList() {
        newProductList = Product.dao.getPlatformNewProductList();
        setAttr("newProductList", newProductList);
        wapTemplatePath("new_product_list.html");
    }

    @Clear
    @Before(CommonInterceptor.class)
    public void hotProductList() {
        hotProductList = Product.dao.getPlatformHotProductList();
        setAttr("hotProductList", hotProductList);
        wapTemplatePath("hot_product_list.html");
    }
}
